import pandas as pd

pathName = ["jieba_cutForSearch", "jieba_cutAll", "pkuseg", "thulac"]


def getSearchOneDayData(index):
    try:
        single_data = pd.read_csv('data/SogouSearchDirectory/SogouQ/access_log.200608' + index + '.decode.filter',
                                  sep='\t| ',
                                  on_bad_lines="skip",
                                  encoding="gbk",
                                  encoding_errors="ignore",
                                  header=None,
                                  names=["user_id", "word", "rank", "seq_num", "url"]
                                  )
        return single_data
    except FileNotFoundError:
        single_data = None
        return single_data


def getSearchHandledData(index, cutType):
    try:
        handled_data = pd.read_csv(
            "data/SogouSearchDirectory/HandledData/" + pathName[cutType] + "/200608" + index + ".csv",
            sep='\t| ',
            on_bad_lines="skip",
            encoding="gbk",
            encoding_errors="ignore",
            header=None,
            usecols=["word", "divide_result"]
            )
        return handled_data
    except FileNotFoundError:
        handled_data = None
        return handled_data


def getMatchHandledData():
    try:
        match_data = pd.read_csv("data/SogouMatchData/HandledData/searchInfo.csv")
        return match_data
    except FileNotFoundError:
        return None
